package cn.sciento.boot.tenant.hiam.api.controller.v1;


import cn.sciento.core.iam.ResourceLevel;
import cn.sciento.swagger.annotation.Permission;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import java.util.Map;
import cn.sciento.boot.platform.lov.annotation.ProcessLovValue;
import cn.sciento.boot.tenant.hiam.app.service.TenantInitConfigService;
import cn.sciento.boot.tenant.hiam.domain.entity.TenantInitConfig;
import cn.sciento.core.base.BaseController;
import cn.sciento.core.util.Results;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController("tenantInitConfigController.v1")
@RequestMapping({"/v1/tenant-init-configs"})
public class TenantInitConfigController extends BaseController {
  @Autowired
  private TenantInitConfigService tenantInitConfigService;
  
  @ApiOperation("租户初始化处理器配置列表")
  @Permission(level = ResourceLevel.SITE)
  @GetMapping({"/list"})
  @ProcessLovValue(targetField = {"body"})
  public ResponseEntity<List<TenantInitConfig>> selectTenantInitConfigList(TenantInitConfig tenantInitConfig) {
    List<TenantInitConfig> list = this.tenantInitConfigService.selectTenantInitConfigList(tenantInitConfig);
    return Results.success(list);
  }
  
  @ApiOperation("格式化查询租户初始化处理器配置")
  @Permission(level = ResourceLevel.SITE)
  @GetMapping({"/map"})
  public ResponseEntity<Map<String, Map<String, List<TenantInitConfig>>>> selectTenantInitConfigMap() {
    Map<String, Map<String, List<TenantInitConfig>>> result = this.tenantInitConfigService.selectTenantInitConfigMap();
    return Results.success(result);
  }
}
